package cuiyt.juc.volatiletest;


/**
 * @author cyt
 * @create 2020-09-05 20:58
 */
public class demo4 {
    volatile int a = 0;
    public static void main(String[] args) {
        for (int i = 0; i < 20; i++) {
            new Thread(() -> {
                System.out.println(new demo4().test());
            }, i + "").start();
        }
    }

    public int test() {
        System.out.println("初始化");
        a = 1;
        while (a == 0) {

        }
        System.out.println("初始化之后");
        return a;
    }
}

